package com.jarvis.user.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.jarvis.user.entity.UserRecordEntity;
import com.jarvis.user.service.UserRecordService;
import com.jarvis.common.utils.PageUtils;
import com.jarvis.common.utils.R;



/**
 * 创作记录表
 *
 * @author gongxin
 * @email 19910320678@163.com
 * @date 2023-03-31 10:56:20
 */
@RestController
@RequestMapping("user/userrecord")
public class UserRecordController {
    @Autowired
    private UserRecordService userRecordService;


    @RequestMapping("/userlist")
    //  @RequiresPermissions("user:userrecord:list")
    public R userlist(@RequestParam Map<String, Object> params,@RequestHeader Map<String, String> headers){
        String uid = headers.get("uid");
        PageUtils page = userRecordService.queryUserPage(params,uid);
        return R.ok().put("page", page);
    }


    /**
     * 列表
     */
    @RequestMapping("/list")
  //  @RequiresPermissions("user:userrecord:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userRecordService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
   // @RequiresPermissions("user:userrecord:info")
    public R info(@PathVariable("id") Long id){
		UserRecordEntity userRecord = userRecordService.getById(id);
        return R.ok().put("userRecord", userRecord);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
  //  @RequiresPermissions("user:userrecord:save")
    public R save(@RequestBody UserRecordEntity userRecord){
		userRecordService.save(userRecord);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
  //  @RequiresPermissions("user:userrecord:update")
    public R update(@RequestBody UserRecordEntity userRecord){
		userRecordService.updateById(userRecord);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
   // @RequiresPermissions("user:userrecord:delete")
    public R delete(@RequestBody Long[] ids){
		userRecordService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
